package com.oocl.multiple_threads_download.analyzer;

import java.io.File;

import com.oocl.multiple_threads_download.pojo.DownloadParams;

public class DownloadAnalyzer {

	public DownloadParams anaylzeFile(String filePath){
		File file = new File(filePath);
		if(!file.exists()||file.isDirectory())
			return null;
		DownloadParams params = new DownloadParams();
		params.setFileByteSize(file.length());
		
		long restBytes = file.length()%10240;///余下一个buf长度以内的数据
		long count = file.length()/10240;///除了最后一个线程要做多一点，其余线程要做的次数
		
		params.setTargetFilePath(filePath);
		params.setBufLen(10240);
		params.setRestByteSize(restBytes);
		params.setThreadCount(10);
		params.setAvgReadCount(count);
		return params;
	}
	
}
